'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE, BOOLEAN } = app.Sequelize;

  const InviteFriend = app.model.define('invite_friend', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    user_id: INTEGER,
    friend_id: INTEGER,
    unlock: BOOLEAN,
    create_time: DATE,
    update_time: DATE,
    delete_time: DATE
  });

  InviteFriend.associate = function() {
    app.model.InviteFriend.belongsTo(app.model.User, {
      as: 'user',
      foreignKey: 'user_id',
      targetKey: 'id'
    });

    app.model.InviteFriend.belongsTo(app.model.User, {
      as: 'friend',
      foreignKey: 'friend_id',
      targetKey: 'id'
    });
  }

  return InviteFriend;
};
